/******************************************************************************************
 * Import
 ******************************************************************************************/

// module
import Taro, { Component } from '@tarojs/taro'
import { Swiper } from '@tarojs/components'

// project
import { CPage, CContent, CHeader, CFooter, CFloat, CAround, CBetween, CCenter, CRow, CWrap, CLine, CHand, CItemX, CItemY, CText, CLabel, CSvg, CImage, CButton } from '../../library/comp';
import { Base64, Gen, Time, Zip, Session, Storage, Http } from '../../library/func';
import Icon from '../../project/style/icon';

import DoHttp from '../../project/func/http/http';

/******************************************************************************************
 * Export Class
 ******************************************************************************************/

export default class Detail extends Component {

	/*------------------------------------------------------------------------------------
	 * 初始化
	 *-----------------------------------------------------------------------------------*/
	constructor(props) {
		super(props);
	}

	/*------------------------------------------------------------------------------------
	 * 生命周期
	 *-----------------------------------------------------------------------------------*/
	// didMount
	componentDidMount() {

	}

	// didShow
	componentDidShow(){
		// Storage.get({
        //     key:'token',
        //     success:(res)=>{
		// 		if(res != null){
		// 			var pages = getCurrentPages();
		// 			var prevPage = pages[pages.length - 2]; 
		// 			//tab页面的路由
		// 			var route_arr = ['screen/home/index', 'screen/product/cat', 'screen/vip/index', 'screen/order/cart', 'screen/user/home/index'];
		// 			if(route_arr.indexOf(prevPage.route) != -1){
		// 				console.log("跳回tab页面");
		// 				wx.switchTab({
		// 					url:"/"+prevPage.route,
		// 				})
		// 			}else{
		// 				wx.navigateBack({
		// 					delta: 1
		// 				})                    
		// 			}	
		// 		}
        //     }
        // })

	}
	
	/*------------------------------------------------------------------------------------
	 * 事件处理
	 *-----------------------------------------------------------------------------------*/
	// onClick
	onClick = (e)=> {

	}
    
    // onRedirect
    onRedirect = (url, e)=> {
        wx.redirectTo({
            url: url
        })
    }

    // onNavigate
    onNavigate = (url, e)=> {

    }

	/*------------------------------------------------------------------------------------
	 * 自定义方法
	 *-----------------------------------------------------------------------------------*/

    getUserInfo(e) {
		// wx.login({
		// 	success: res => {
		// 	  DoHttp.Cget({
		// 		url:'he_rushbuy/worker/getopenid.php',
		// 		data:{
		// 		  js_code:res.code
		// 		},
		// 		success:(res) => {
		// 		},
		// 		error(res){
					// let openid = res.openid;
					let openid = 'oXLnM4vHaPL7rql4JTe9d9wQTalI';
					DoHttp.Login(openid, e.detail.userInfo);
		// 		}
		// 	  })
		// 	}
		// })
		

	}



	config = {
        navigationBarTitleText: '认证微信身份',
        navigationBarBackgroundColor: '#dd2f3c',
        navigationBarTextStyle: '#fff'
    }

	/*------------------------------------------------------------------------------------
	 * 渲染
	 *-----------------------------------------------------------------------------------*/
	render () {
		return (
			<CPage>
				<CContent style="background:#F7F7F7">
					<Button openType="getUserInfo" onGetUserInfo={this.getUserInfo}>认证微信个人信息</Button>
				</CContent>
			</CPage>
		)
	}
}


